package riofrio.examples;

import riofrio.TreeNode;
import static riofrio.TreeNode.with;
import riofrio.DepthFirstWalk;

/**
 *
 * @author Victor Hugo Herrera Maldonado
 */
public class Printing {
    
    public static void main(String[] args) {
        TreeNode<String> root=
                with("A")
                    .children(
                        with("A1")
                            .childrenWith("A1.1",  "A1.2"),
                        with("A2")
                            .childrenWith("A2.1", "A2.2"));
        new DepthFirstWalk<>(root, DepthFirstWalk.Order.PRE_ORDER)
            .forEach(node -> {
                if(node.isParent()) {
                    System.out.printf("+ %s%n", node.getContent());
                }else{
                    System.out.printf("- %s%n", node.getContent());
                }
            });
    }

}
